package com.nuoniu.sibanyun.service.production.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.nuoniu.sibanyun.entity.production.VProductionOrderDetail;
import com.nuoniu.sibanyun.mapper.production.VProductionOrderDetailMapper;
import com.nuoniu.sibanyun.service.production.IVProductionOrderDetailService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 生产订单明细 服务实现类
 * </p>
 *
 * @author 小啊刚
 * @since 2021-03-08
 */
@Service
public class VProductionOrderDetailServiceImpl extends ServiceImpl<VProductionOrderDetailMapper, VProductionOrderDetail> implements IVProductionOrderDetailService {

    @Override
    public void removeByOrderId(Long orderId) {
        UserInfo userInfo = UserThreadLocal.get();
        QueryWrapper<VProductionOrderDetail> wrapper = new QueryWrapper<>();
        wrapper.eq("order_id", orderId);
        wrapper.eq("company_id",userInfo.getCompanyId());
        remove(wrapper);
    }

    @Override
    public List<VProductionOrderDetail> getOrderDetails(Long orderId) {
        UserInfo userInfo = UserThreadLocal.get();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("company_id",userInfo.getCompanyId());
        queryWrapper.eq("order_id",orderId);
        List<VProductionOrderDetail> list = list(queryWrapper);
        return list;
    }
}
